{% macro product_breadcrumbs(product, additional_items = []) %}
    {% from '@SyliusShop/shared/breadcrumbs.html.twig' import breadcrumbs as breadcrumbs %}

    {% set items = items|default([])|merge([{
        path: path('sylius_shop_homepage'),
        label: 'sylius.ui.home'|trans
    }]) %}

    {% if product.mainTaxon is not null %}
        {% set taxon = product.mainTaxon %}
        {% set ancestors = taxon.ancestors|reverse %}

        {% for ancestor in ancestors %}
            {% if ancestor.isRoot() or not ancestor.enabled %}
                {% set items = items|merge([{ label: ancestor.name }]) %}
            {% else %}
                {% set items = items|merge([{
                    path: path('sylius_shop_product_index',{'slug': ancestor.slug, '_locale': ancestor.translation.locale}),
                    label: ancestor.name }]) %}
            {% endif %}
        {% endfor %}

        {% if taxon.enabled %}
            {% set items = items|merge([{
                path: path('sylius_shop_product_index', {'slug': taxon.slug, '_locale': taxon.translation.locale}),
                label: taxon.name }]) %}
        {% else %}
            {% set items = items|merge([{ label: taxon.name }]) %}
        {% endif %}
    {% endif %}

    {% if additional_items|length > 0 %}
        {% set items = items|merge([{
            label: product.name,
            path: path('sylius_shop_product_show', {'slug': product.slug, '_locale': product.translation.locale}) }]) %}
    {% else %}
        {% set items = items|merge([{ label: product.name, active: true }]) %}
    {% endif %}

    {% set items = items|merge(additional_items) %}

    {{ breadcrumbs(items) }}
{% endmacro %}
